import vtkLookupTable from "@kitware/vtk.js/Common/Core/LookupTable";
import vtkPolyData from "@kitware/vtk.js/Common/DataModel/PolyData";
import vtkDataArray from "@kitware/vtk.js/Common/Core/DataArray";
import vtkRenderer from "@kitware/vtk.js/Rendering/Core/Renderer";
import vtkInteractorObserver from "@kitware/vtk.js/Rendering/Core/InteractorObserver.js";
import vtkPoints from "@kitware/vtk.js/Common/Core/Points";
import vtkCellArray from "@kitware/vtk.js/Common/Core/CellArray";
import vtkPolyDataNormals from "@kitware/vtk.js/Filters/Core/PolyDataNormals";

//@ts-ignore
const { computeWorldToDisplay } = vtkInteractorObserver;

export interface LookUpTableOptions {
  /**
   * The number of colors in the table.
   */
  numberOfColors?: number;
  /**
   * The range of the table.
   */
  range?: [number, number];
  /**
   * The colors of the table.
   */
  colors?: string[];
}

export function createLookUpTable(options: any = {}) {
  return vtkLookupTable.newInstance(options);
}

export function createPolyData() {
  return vtkPolyData.newInstance();
}

export function createDataArray() {
  return vtkDataArray.newInstance();
}

export function createPoints() {
  return vtkPoints.newInstance();
}

export function createCellData() {
  return vtkCellArray.newInstance();
}

export function createPolyDataNormals() {
  return vtkPolyDataNormals.newInstance();
}

// * 暴露类型
export interface BRenderer extends vtkRenderer {}

export function worldToDisplay(r: BRenderer, x: number, y: number, z: number) {
  return computeWorldToDisplay(r, x, y, z);
}
